#include "SettingWindow.h"
#include "NetworkEngine/NetworkFileManager.h"
#include "Common/Common.h"
#include "SPlayerWindow.h"
#include "NetworkEngine/CachedFileManager.h"

using namespace System;
using namespace SPlayer;
using namespace SPlayer::Common;
using namespace SPlayer::Network;

SPlayer::SettingWindow::SettingWindow(SPlayerWindow ^parent) : parent(parent)
{
    InitializeComponent();

    this->folderBrowserDialog->SelectedPath = Music::CachedFileManager::cacheDirectory;
    this->fileSavePathTextBox->Text = Music::CachedFileManager::cacheDirectory;
}

SPlayer::SettingWindow::~SettingWindow()
{
    if (components)
    {
        delete components;
    }
}

System::Void SPlayer::SettingWindow::browseFileSavePathButton_Click(System::Object^ sender, System::EventArgs^ e)
{
    this->folderBrowserDialog->ShowDialog();
    this->fileSavePathTextBox->Text = this->folderBrowserDialog->SelectedPath;
}

System::Void SPlayer::SettingWindow::okButton_Click(System::Object^ sender, System::EventArgs^ e)
{
    Music::CachedFileManager::cacheDirectory = this->fileSavePathTextBox->Text;

    this->Close();
}
